﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.peddlerUI.peddlerMarketUI.data {
    import Classes.*;
    import Classes.util.*;
    import Classes.inventory.*;
    import Modules.peddler.*;

    public class PeddlerData extends PeddlerModel {

        private var m_restTime:Number;

        public function PeddlerData(_arg1:Boolean=false, _arg2:String="", _arg3:String="", _arg4:String="", _arg5:String="", _arg6:Number=0, _arg7:String=""){
            super(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7);
        }
        public function get peddler_url():String{
            return (item.icon);
        }
        public function get peddler_name():String{
            return (Global.gameSettings.getItemFriendlyName(item.name));
        }
        public function get hasFood():Boolean{
            return (!((m_pdlr_state == STATE_REST)));
        }
        public function get info():String{
            var _local3:int;
            var _local4:Number;
            var _local5:Number;
            var _local6:String;
            var _local1 = "";
            var _local2:String = Global.player.getFriendName(m_hostId);
            if (m_pdlr_state == HarvestableResource.STATE_PLOWED){
                _local1 = (ZLoc.t("Dialogs", ("peddler_" + m_pdlr_state)) + "\n");
                _local3 = Global.player.commodities.getCount(Commodities.GOODS_COMMODITY);
                if (_local3 < item.commodityReq){
                    _local1 = (_local1 + ZLoc.t("Dialogs", "requireGood", {count:item.commodityReq}));
                } else {
                    _local1 = (_local1 + ZLoc.t("Dialogs", "gotoPutPeddler"));
                };
            };
            if (m_pdlr_state == HarvestableResource.STATE_PLANTED){
                _local1 = (ZLoc.t("Dialogs", ("peddler_" + m_pdlr_state), {name:_local2}) + "\n");
                if (m_allowed == true){
                    _local1 = (_local1 + ZLoc.t("Dialogs", "peddler_allowed"));
                } else {
                    _local1 = (_local1 + ZLoc.t("Dialogs", "peddler_unallowed"));
                };
            };
            if (m_pdlr_state == HarvestableResource.STATE_GROWN){
                _local1 = (ZLoc.t("Dialogs", ("peddler_" + m_pdlr_state)) + "\n");
                _local1 = (_local1 + ZLoc.t("Dialogs", "Peddler_Grown", {name:_local2}));
            };
            if (m_pdlr_state == PeddlerModel.STATE_REST){
                _local4 = Global.gameSettings.getNumber("inGameDaySeconds");
                _local5 = ((GlobalEngine.serverTime - m_plantTime) / 1000);
                _local5 = ((_local5 < 0)) ? 0 : _local5;
                _local6 = GameUtil.formatMinutesSeconds(_local5);
                _local1 = (ZLoc.t("Dialogs", ("peddler_" + m_pdlr_state)) + "\n");
                _local1 = (_local1 + ZLoc.t("Dialogs", "Peddler_Sleep"));
            };
            return (("\n" + _local1));
        }
        public function set restSleepTimeSecond(_arg1:Number):void{
            this.m_restTime = _arg1;
        }
        public function get restSleepTimeSecond():Number{
            var _local1:Number;
            var _local2:Number;
            var _local3:Number;
            var _local4:Number;
            this.m_restTime = -1;
            if (m_pdlr_state == PeddlerModel.STATE_REST){
                _local1 = ((GlobalEngine.serverTime - m_plantTime) / 1000);
                _local2 = Number(item.xml.sleepTime[0]);
                _local3 = Global.gameSettings.getNumber("inGameDaySeconds");
                _local4 = (_local2 * _local3);
                this.m_restTime = (_local4 - _local1);
            };
            return (this.m_restTime);
        }

    }
}//package Display.peddlerUI.peddlerMarketUI.data 
